/*
 * CS_REQ_GAME_INFO.cpp
 *
 *  Created on: 2014. 2. 11.
 *      Author: mega
 */

#include "../../Command.h"
#include "../../User.h"
#include "../../NResource/Static.h"

namespace ProjectZ { namespace NCommand {

static void SendFailGameInfo(User * pUser)
{
	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	*pAck << static_cast<uint8_t>(0);
	pAck->MakePacket(CMD_SC_REQ_GAME_INFO);
	pUser->Send(pAck);
}

void Command::CS_REQ_GAME_INFO(User * pUser, ::Network::Packet * pPacket)
{
/*	/// 서버관리가 되는 게임 데이터 마을 입장 시 1회만 요청
	CS_REQ_GAME_INFO                                      0x0959
	{
	}

	SC_REQ_GAME_INFO                                      0x095A
	{
	           u8 u8count;
	           {
	                     u32 u32value;               /// 0 : 최대 레벨  1:열쇠시간(분단위)
	           }
	}*/

	PREPARE_PACKET;

	int maxLevel = NResource::Static::InstancePtr()->GetCommon()->GetLimitLevel(pUser);
	if (-1 == maxLevel)
	{
		DEBUGLOG("%s : maxLevel lookup fail", __FUNCTION__);
		SendFailGameInfo(pUser);
		return;
	}

	int recoveryMinute = NResource::Static::InstancePtr()->GetStaminaResource()->GetRecoveryMinute(pUser);
	if (-1 == recoveryMinute)
	{
		DEBUGLOG("%s : recoveryMinute lookup fail", __FUNCTION__);
		SendFailGameInfo(pUser);
		return;
	}

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	//*pAck << static_cast<uint8_t>(3); // client 측에서 array의 size를 나타낸다.
	*pAck << static_cast<uint8_t>(4); // client 측에서 array의 size를 나타낸다.
	*pAck << static_cast<uint32_t>(maxLevel);
	*pAck << static_cast<uint32_t>(recoveryMinute);

	// Added by spencer(2014.07.02)
	// 성기사 클래스 추가 컨텐츠 open/close 여부 전달
	if ( false == NResource::Static::Instance().GetContentsOpenResource()->IsOpen(ContentsOpen::NEW_CLASS_PALADIN) )
		*pAck << static_cast<uint32_t>(0); // 미오픈
	else
		*pAck << static_cast<uint32_t>(1); // 오픈

	// Guild on / off ..
	if ( false == NResource::Static::Instance().GetContentsOpenResource()->IsOpen(ContentsOpen::GUILD) )
		*pAck << static_cast<uint32_t>(0); // 미오픈
	else
		*pAck << static_cast<uint32_t>(1); // 오픈

		
	pAck->MakePacket(CMD_SC_REQ_GAME_INFO);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/
